/**
 * 
 */
package com.vincent.action.web;

import java.io.IOException;
import java.util.HashMap;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.vincent.action.basic.BasicAction;
import com.vincent.pojo.User;
import com.vincent.service.IndexService;
import com.zhj.util.UTIL;

/**
 * 作者： Vincent 创建日期： 2014年4月20日 上午9:59:31 项目名字： MyForum
 */
@Component("indexAction")
@Scope("prototype")
@ParentPackage("struts-default")
@Namespace("/")
public class IndexAction extends BasicAction {
	@Resource
	private IndexService indexService;

	@Action(value = "index", results = { @Result(name = "ok", location = "/WEB-INF/web/index.jsp") })
	public String index() {
		UTIL.getRequest().setAttribute("indexSubjects", indexService.getSubjects());
		return "ok";
	}

	@Action(value = "indexCheckIN")
	public String indexCheckIN() throws IOException {

		User user = (User) session.getAttribute("user");

		HashMap<String, Integer> hashMap = indexService.checkIn(user);

		response.getWriter().print(JSON.toJSONString(hashMap));

		return null;
	}
}
